﻿using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using TR.AppService.AppService.XSDD_GuanLi;
using TR.AppService.Dto;
using TR.AppService.Dto.XSddDto;
using TR.Domain.Entity;
using TR.Domain.Entity.XSDDGL;

namespace TR.WebApi.Controllers.XSDD_GuanLiControllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class XSDDControllers : ControllerBase
    {
        private readonly IXsddAppService Ixsdd;

        public XSDDControllers(IXsddAppService Ixsdd)
        {
            this.Ixsdd = Ixsdd;
        }

        //销售订单分页
        [HttpGet]
        public async Task<DtoFenYe<XSdd>> XSddFenYeAsync(int mys,int dqy,string? qsj,string? hsj, [FromQuery] tjXsddDto xs)
        {
            return await Ixsdd.XsddFenYeAsync(mys, dqy, qsj, hsj, xs);
        }

        //批量删除
        [HttpPut]
        public async Task<bool> XsddDelete(List<int> isdel)
        {
            return await Ixsdd.XsddDelete(isdel);
        }

        //批量审核
        [HttpPut]
        public async Task<bool> XsddShenHe(List<int> Bian, string states, string sureman, string suredate)
        {
            return await Ixsdd.XsddShenHe(Bian, states, sureman, suredate);
        }

        //批量撤销
        [HttpPut]
        public async Task<bool> XsddCheXiao(List<int> Bina)
        {
            return await Ixsdd.XsddCheXiao(Bina);
        }

        //客户信息查询
        [HttpGet]
        public async Task<List<bs_Customer>> KHSelect()
        {
            return await Ixsdd.KHSelect();
        }

        //根据客户编号查询客户信息
        [HttpGet]
        public async Task<bs_Customer> KHBHSelect(string bh)
        {
            return await Ixsdd.KHBHSelect(bh);
        }

        //销售订单增加
        [HttpPost]
        public async Task<bool> XsddInsert([FromBody] XsddAddData xsxz)
        {
            bool jieguo = await Ixsdd.XsddInsert(xsxz.jcxx, xsxz.xsmxe);
            if (jieguo)
            {
                return true;
            }
            else
            {
                return false;

            }
        }

        //销售订单修改
        [HttpPut]
        public async Task<bool> XsddUpdate([FromBody] XsddAddData xsxz)
        {
            bool jieguo = await Ixsdd.XsddUpdate(xsxz.jcxx, xsxz.xsmxe);
            if (jieguo)
            {
                return true;
            }
            else
            {
                return false;

            }
        }

        //销售基本信息查询
        [HttpGet]
        public async Task<wh_Sale_h> XsddJbxxSelect(string bh)
        {
            return await Ixsdd.XsddJbxxSelect(bh);
        }

        //销售明细查询
        [HttpGet]
        public async Task<List<XsddXsxqCX>> XsddXsxqSelect(string bh)
        {
            return await Ixsdd.XsddXsxqSelect(bh);
        }

        //销售添加商品查询
        [HttpGet]
        public async Task<List<XsddTjSP>> XsddTjSPSelect()
        {
            return await Ixsdd.XsddTjSPSelect();
        }
    }
}
